package com.zookeeper.mine.study.dao;

import com.zookeeper.mine.study.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserDao {

    @Select("select * from user where id=#{id}")
    User findById(@Param("id")Long id);

    @Insert("insert into user(name) values (#{user.name})")
    @Options(useGeneratedKeys = true, keyProperty = "user.id")
    void insert(@Param("user") User user);

    @Select("select * from user")
    List<User> findAll();

    @Delete("delete from user where id=#{id}")
    void delete(@Param("id") Long id);

    @Insert("insert into user(id,name) values (#{user.id},#{user.name})")
    @Options(useGeneratedKeys = true, keyProperty = "user.id")
    void insert2(@Param("user") User user);
}
